﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HMS.Data
{
    public class ReportService
    {
        public List<USP_GetLocationBasedPatientCount_Result> LocationBasedPatientCount(DateTime startDate, DateTime endDate,int clinicId, int locId, int docId)
        {
            
            
            List<USP_GetLocationBasedPatientCount_Result> locationBasedPatientCount = new List<USP_GetLocationBasedPatientCount_Result>();
            using (var dt = new HMSEntities())
            {
                //var patientLocationCount = dt.Patients.GroupBy(x => x.Patient_Location_Pin);
                //return patientLocationCount.Select(y => new Patient() { Patient_Location_Pin = y.Key, Patient_id = y.Count() }).ToList();
                locationBasedPatientCount = dt.USP_GetLocationBasedPatientCount(startDate, endDate,clinicId,docId, locId ).ToList<USP_GetLocationBasedPatientCount_Result>();
                //var xyz = locationBasedPatientCount.GroupBy(x => x.Patient_Location_Name).Select(y => new USP_GetLocationBasedPatientCount_Result() { Patient_Location_Name = y.Key, PatientCount = y.Count() }).ToList(); ;
            }
            return locationBasedPatientCount;
            
        }

        public List<USP_GetFinanceReport_Result> GetFinanceReport(DateTime startDate, DateTime endDate, int clinicId, int locId, int docId)
        {


            List<USP_GetFinanceReport_Result> locationBasedPatientCount = new List<USP_GetFinanceReport_Result>();
            using (var dt = new HMSEntities())
            {
                var patientLocationCount = dt.Patients.GroupBy(x => x.Patient_Location_Pin);
                //return patientLocationCount.Select(y => new Patient() { Patient_Location_Pin = y.Key, Patient_id = y.Count() }).ToList();
                locationBasedPatientCount = dt.USP_GetFinanceReport(startDate, endDate, clinicId, docId, locId).ToList<USP_GetFinanceReport_Result>();
            }
            return locationBasedPatientCount;

        }
    }
}
